package edu.ptu.acl.dto;

import edu.ptu.acl.entity.User;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.springframework.beans.BeanUtils;

@Data
public class UserTransferDto extends User {

    private Boolean disabled = true;

    public static UserTransferDto copyUser2Dto(User user){
        UserTransferDto userTransferDto = new UserTransferDto();
        BeanUtils.copyProperties(user,userTransferDto);
        return userTransferDto;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        UserTransferDto that = (UserTransferDto) o;

        return new EqualsBuilder()
                .appendSuper(super.equals(o))
                .append(disabled, that.disabled)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .appendSuper(super.hashCode())
                .append(disabled)
                .toHashCode();
    }
}
